package his.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import his.entity.PatientCosts;
import his.entity.Register;
import his.persistence.PatientCostsMapper;
import his.persistence.RegisterMapper;
import his.service.CheckSpendService;
import org.example.his.common.api.CommonResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;


@Service
public class CheckSpendServiceImpl implements CheckSpendService {
    @Autowired
    PatientCostsMapper patientCostsMapper;
    @Autowired
    RegisterMapper registerMapper;

    //查询消费明细
   public CommonResponse<List<PatientCosts>> get_costs_list(int CaseNumber , String RealName ) {
       QueryWrapper<Register> registerQueryWrapper = new QueryWrapper<Register>();
       registerQueryWrapper.eq("CaseNumber" , CaseNumber)
                          .eq("RealName", RealName);
       Register register = registerMapper.selectOne(registerQueryWrapper);
       int RegistId = register.getId();
       QueryWrapper<PatientCosts> patientCostsQueryWrapper = new QueryWrapper<PatientCosts>();
       patientCostsQueryWrapper.eq("RegistId" , RegistId);
       List<PatientCosts> patientCostsList = patientCostsMapper.selectList(patientCostsQueryWrapper);

       return CommonResponse.createForSuccess("查询成功" , patientCostsList);
   }
}
